from starlette.endpoints import HTTPEndpoint
from starlette.responses import JSONResponse

from database import Session, engine
import datetime
from dao import DaoPendingProSupType
from dao import DaoWorkRecord


class PendingProSupType(HTTPEndpoint):

    async def get(self, request):
        session = Session()
        try:
           bureauid = request.query_params["bureauid"]
           stationid = request.query_params["stationid"]
           return  DaoPendingProSupType.get_pending_pro_sup_type(session, bureauid, stationid)
        finally:
            session.close()

class PendingProSupTypeDetail(HTTPEndpoint):

    async def get(self, request):
        session = Session()
        try:
            bureauid = request.query_params["bureauid"]
            problemid = request.query_params["problemid"]
            stationid = request.query_params["stationid"]
            return DaoWorkRecord.get_pending_pro_suptype_detail(session, bureauid, stationid, problemid)
        finally:
            session.close()